mtstr = "buider and his friends"

#index方法
value = mtstr.index("and")
print(f"{value}")

#replac方法
new_mtstr = mtstr.replace("and", "&")
print(new_mtstr)

#split方法
split_mtstr = mtstr.split(" ")
print(split_mtstr) #得到一个列表

#strip方法:用于删除字符串开头和结尾指定字符（默认为空格）
  #不传参数：去除前后空格
blank_space_mtstr = "  buider and his friends  "
blank_space_mtstr_list = blank_space_mtstr.strip()
print(blank_space_mtstr_list)
  #传入参数：去除传入的参数
mtstr_list = mtstr.strip("bsud") #拆分成小子串"b""s""u""d"
print(mtstr_list)

#统计某元素出现次数
print(f"i : {mtstr.count('i')} times ")

#字符串的遍历
for i in mtstr:
    print(i, end=' ')

index = 0
while index < len(mtstr):
    print(mtstr[index], end=' ')
    index += 1